<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<!--

    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:cc="http://java.sun.com/jsf/composite/ajax">
<h:head>
    <title>Eval Script Tests</title>
</h:head>
<h:body>

    <span id="target">Pending</span> <br/>

    <script type="text/javascript">
        var target;
        window.fileMarker = 0;
        var checkPass = function checkPass() {
            target = document.getElementById('target');
            if (typeof marker === 'undefined') {
                target.innerHTML = "Failed - marker unset";
            } else {
                target.innerHTML = "PASSED";
            }
        };
        var checkPassFile = function checkPassFile(data) {
            target = document.getElementById("target");
            if (window.fileMarker == 2) {
                target.innerHTML = "PASSED";
            } else {
                target.innerHTML = "Failed - file marker is " + window.fileMarker + ", should be 2";
            }
        };
        var evalFileEvent = function evalFileEvent(data) {
            if (data.status == "success") {
                // need a sleep function, to wait for file load
                setTimeout(checkPassFile,200);
            }
        };
    </script>
    <div id="updated"></div>
    <cc:evalTestFile id="evalFile"/>
    <cc:evalTestInline id="evalInline"/>
    <h:form>
        <h:commandButton id="doEval" value="doEval" action="#{evalScriptBean.doEval}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers except K
        <br/>
        <h:commandButton id="doInline" value="doInline" action="#{evalScriptBean.doInline}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="doInlineCC" value="doInlineCC">
            <f:ajax execute="@none" render=":evalInline"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="doFile" value="doFile" action="#{evalScriptBean.doInline}">
            <f:ajax execute="@none" render=":evalFile" onevent="evalFileEvent"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="doUpdateRootAllEval" value="doUpdateRootAllEval" action="#{evalScriptBean.doUpdateRootAllEval}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="doUpdateRootSimpleEval" value="doUpdateRootSimpleEval" action="#{evalScriptBean.doUpdateRootSimpleEval}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="doUpdateBodyTagEval" value="doUpdateBodyTagEval" action="#{evalScriptBean.doUpdateBodyTagEval}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers
        <br/>
        <h:commandButton id="insertBeforeEval" value="insertBeforeEval" action="#{evalScriptBean.insertBeforeEval}">
            <f:ajax execute="@this" render="@none"/>
        </h:commandButton>
        Works in all browsers
        <br/>
    </h:form>
</h:body>
</html>
